﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using Project.Util;

namespace EStore.Core.Catalogs
{
    public class Product : IAggregateRoot<Product, string, IProductRepository>
    {
        static IProductRepository _repository
        {
            get
            {
                return EngineContext.Current.ContainerManager.Resolve<IProductRepository>();
            }
        }

        public string Code { get; set; }

        public string Name { get; set; }

        public decimal SalePrice { get; set; }

        public int SKU { get; set; }

        public static Product FindByCode(string productCode)
        {
            Contract.Requires<InvalidOperationException>(!string.IsNullOrEmpty(productCode), "查询产品号不能为空");
            return _repository.FindByCode(productCode);
        }

        public bool CanBeSaved
        {
            get { throw new NotImplementedException(); }
        }

        public string ID
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            throw new NotImplementedException();
        }
    }
}
